<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>linux服务 | 学习笔记</title><meta name="author" content="lzoxun"><meta name="copyright" content="lzoxun"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="FTP   文件传输协议，搭建好之后可以通过客户端上传现在服务器的文件  FTP协议，直接以明文传输，安全不太好 终端ftpwindow自带 123456789# 登入&gt; ftpftp&gt; open ip回车 依次输入用户名密码# help 查看支持的命令列表ftp&gt; help     ?# LITERAL PASV 切换被动模式  客户端 服务端 vsftpd 搭建 ftp 环境">
<meta property="og:type" content="article">
<meta property="og:title" content="linux服务">
<meta property="og:url" content="http://example.com/2023/07/22/linux/linux-servers/index.html">
<meta property="og:site_name" content="学习笔记">
<meta property="og:description" content="FTP   文件传输协议，搭建好之后可以通过客户端上传现在服务器的文件  FTP协议，直接以明文传输，安全不太好 终端ftpwindow自带 123456789# 登入&gt; ftpftp&gt; open ip回车 依次输入用户名密码# help 查看支持的命令列表ftp&gt; help     ?# LITERAL PASV 切换被动模式  客户端 服务端 vsftpd 搭建 ftp 环境">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png">
<meta property="article:published_time" content="2023-07-22T07:14:09.681Z">
<meta property="article:modified_time" content="2023-07-22T07:14:09.681Z">
<meta property="article:author" content="lzoxun">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="http://example.com/2023/07/22/linux/linux-servers/index.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = {
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.xml","preload":true,"top_n_per_article":1,"unescape":true,"languages":{"hits_empty":"找不到您查询的内容：${query}","hits_stats":"共找到 ${hits} 篇文章"}},
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"簡"},
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  dateSuffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: {"chs_to_cht":"你已切换为繁体","cht_to_chs":"你已切换为简体","day_to_night":"你已切换为深色模式","night_to_day":"你已切换为浅色模式","bgLight":"#49b1f5","bgDark":"#1f1f1f","position":"bottom-left"},
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: true,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: false,
  },
  autoDarkmode: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'linux服务',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2023-07-22 15:14:09'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
    win.getCSS = (url,id = false) => new Promise((resolve, reject) => {
      const link = document.createElement('link')
      link.rel = 'stylesheet'
      link.href = url
      if (id) link.id = id
      link.onerror = reject
      link.onload = link.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        link.onload = link.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(link)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          const now = new Date()
          const hour = now.getHours()
          const isNight = hour <= 6 || hour >= 18
          if (t === undefined) isNight ? activateDarkMode() : activateLightMode()
          else if (t === 'light') activateLightMode()
          else activateDarkMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><meta name="generator" content="Hexo 6.3.0"></head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><script>(()=>{
  const $loadingBox = document.getElementById('loading-box')
  const $body = document.body
  const preloader = {
    endLoading: () => {
      $body.style.overflow = ''
      $loadingBox.classList.add('loaded')
    },
    initLoading: () => {
      $body.style.overflow = 'hidden'
      $loadingBox.classList.remove('loaded')
    }
  }

  preloader.initLoading()
  window.addEventListener('load',() => { preloader.endLoading() })

  if (false) {
    document.addEventListener('pjax:send', () => { preloader.initLoading() })
    document.addEventListener('pjax:complete', () => { preloader.endLoading() })
  }
})()</script><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src= "" data-lazy-src="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">108</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">1</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">0</div></a></div><hr class="custom-hr"/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header"><nav id="nav"><span id="blog-info"><a href="/" title="学习笔记"><span class="site-name">学习笔记</span></a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search" href="javascript:void(0);"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div></div><div id="toggle-menu"><a class="site-page" href="javascript:void(0);"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">linux服务</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2023-07-22T07:14:09.681Z" title="发表于 2023-07-22 15:14:09">2023-07-22</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2023-07-22T07:14:09.681Z" title="更新于 2023-07-22 15:14:09">2023-07-22</time></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="linux服务"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h3 id="FTP"><a href="#FTP" class="headerlink" title="FTP"></a>FTP</h3><blockquote>
<p>  文件传输协议，搭建好之后可以通过客户端上传现在服务器的文件</p>
</blockquote>
<p>FTP协议，直接以明文传输，安全不太好</p>
<h4 id="终端ftp"><a href="#终端ftp" class="headerlink" title="终端ftp"></a>终端ftp</h4><p>window自带</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">登入</span></span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">ftp</span></span><br><span class="line"><span class="meta prompt_">ftp&gt; </span><span class="language-bash">open ip</span></span><br><span class="line">回车 依次输入用户名密码</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="built_in">help</span> 查看支持的命令列表</span></span><br><span class="line"><span class="meta prompt_">ftp&gt; </span><span class="language-bash"><span class="built_in">help</span>     ?</span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">LITERAL PASV 切换被动模式</span></span><br></pre></td></tr></table></figure>

<h4 id="客户端"><a href="#客户端" class="headerlink" title="客户端"></a>客户端</h4><hr>
<h4 id="服务端-vsftpd-搭建-ftp-环境"><a href="#服务端-vsftpd-搭建-ftp-环境" class="headerlink" title="服务端 vsftpd 搭建 ftp 环境"></a>服务端 vsftpd 搭建 ftp 环境</h4><blockquote>
<p>  vsftpd 基于 FTP 协议，解决了ftp一些传输安全问题 </p>
</blockquote>
<ol>
<li><p>关闭防火墙 关闭 selinux</p>
<ol>
<li>vim &#x2F;etc&#x2F;selinux&#x2F;config ；SELINUX&#x3D;enforcing  -&gt; SELINUX&#x3D;disabled</li>
<li>终端 setenforce 1||0 临时开启关闭,  0 管理好像有问题</li>
</ol>
</li>
<li><p>VSFTP链接类型</p>
<ol>
<li>控制链接 （持续连接）-&gt; TCP21 -&gt; 用户收发FTP命令</li>
<li>数据链接 （按需链接）-&gt; TCP20 -&gt; 用于上传下载数据</li>
</ol>
</li>
<li><p>主动模式（Prot）：客户端生成随机端口给服务器</p>
<ol>
<li>服务端打开好21端口，让客户端随时来连</li>
<li>如果登录成功，客户端会生成一个随机端口，Prot模式主动将这端口给服务器，用于接收服务器通过<code>20端口</code>发出的数据</li>
</ol>
</li>
<li><p>被动模式（Pasv）：服务端主动生成数据交互端口给客户端</p>
<ol>
<li>服务端打开好21端口，让客户端随时来连</li>
<li>如果登录成功，客户端向服务端<strong>发送PASV指令</strong>，服务器开发随机端口(需要指定范围)，并把端口告诉客户端<ol>
<li>随机端口 与 主动模式的 20端口地位是一样的，（注意防火墙开发端口）</li>
</ol>
</li>
<li>客户端生成临时端口，与服务器随机端口来与 服务器传输数据</li>
<li>云服务器上你可以连接到服务器上某个端口，但是服务器连接不到你（云服务器最好用被动模式）</li>
</ol>
</li>
<li><p>数据传输模式</p>
<ol>
<li><strong>Binary模式：</strong>不对数据进行处理，适用于<code>可执行文件</code>、<code>压缩文件</code>，<code>图片</code>等</li>
<li><strong>ASCII：</strong>进行文本传输时，自动适应模板操作系统的结束符，回车符等</li>
<li>切换方式 ftp 命令提示符输入 ascii 或 bin 转换</li>
</ol>
</li>
<li><h2 id="安装-安装-vsftpd-systemctl-enable-vsftpd-开机自启服务-systemctl-start-vsftpd-启动服务-netstat-antp-查看21端口是否开启"><a href="#安装-安装-vsftpd-systemctl-enable-vsftpd-开机自启服务-systemctl-start-vsftpd-启动服务-netstat-antp-查看21端口是否开启" class="headerlink" title="安装-   安装 vsftpd-   systemctl enable vsftpd 开机自启服务-   systemctl start vsftpd 启动服务-   netstat -antp 查看21端口是否开启"></a>安装<br>-   安装 <code>vsftpd</code><br>-   <code>systemctl enable vsftpd</code> 开机自启服务<br>-   <code>systemctl start vsftpd</code> 启动服务<br>-   <code>netstat -antp</code> 查看21端口是否开启</h2></li>
<li><p>登录颜色方式</p>
<ol>
<li><p>匿名账户登录</p>
<ol>
<li><p>名称 <code>ftp</code> 或 <code>anonymous</code></p>
</li>
<li><p>无密码，直接回车</p>
</li>
<li><p>默认目录：<code>/var/ftp</code></p>
</li>
<li><p>默认权限： 可下载不可上传 ( 上传权限由两部分组成 )</p>
<ol>
<li><p>主配置文件部分 <code>anon_upload_enable=YES</code></p>
</li>
<li><p>文件系统部分 </p>
<ol>
<li><p><code>/var/ftp</code> 除了所有者之外，组 和 其他人是否有写入权限，一般添加子目录 <code>chmod 添加权限 777</code></p>
</li>
<li><p>本地用户，一般把他的跟文件夹所有者，变成他</p>
</li>
</ol>
</li>
<li><p>不用创建大量用户，但是所有人都能用，都设置完在重启</p>
</li>
</ol>
</li>
<li><p>相关配置一般 <code>anon</code> 开头</p>
</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">匿名用户 常用配置 /etc/vsftpd.conf</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">账户:anonymous或ftp 密码随意</span></span><br><span class="line">anonymous_enable=YES #是否允许匿名访问</span><br><span class="line">anon_root=/usr/local/ftpdir #配置匿名用户根目录(如果无法直接设置777，许在ftpdir创建777权限文件夹，供匿名用户使用)</span><br><span class="line">anon_umask=022 #匿名用户上传的文件，其他人能否操作这些文件，的权限掩码 </span><br><span class="line">anon_upload_enable=YES #是否允许匿名用户上传写入</span><br><span class="line">anon_mkdir_write_enable=YES</span><br><span class="line">anon_other_write_enable=YES</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">root 目录下创建 .message 文件</span></span><br><span class="line">dirmessage_enable=YES # 登录就会显示 .message 的内容 </span><br><span class="line"></span><br><span class="line">no_anon_password=YES #匿名用户不用密码登录</span><br><span class="line">ftp_username=ftpuser #匿名登录后的使用者</span><br><span class="line">anon_world_readable_only=YES　　　　　 　# 开启匿名用户下载权限</span><br></pre></td></tr></table></figure>


</li>
<li><p>本地用户登录</p>
<ol>
<li>账号密码 : <code>本地账户的用户名与密码</code></li>
<li>工作目录：登录用户家目录  <code>drwx------</code></li>
<li>创建访问，不用登录系统的用户(本地 linux 用户)<ol>
<li><code>useradd -s /sbin/ nologin zhangsan</code></li>
</ol>
</li>
<li>相关配置一般<code>local</code>开头，所有用户local配置的是一样的</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">本地用户 /etc/vsftpd.conf</span></span><br><span class="line">local_enable=YES #是否允许本地用户`如root`登录</span><br><span class="line">local_root=/home/ftpuser #设置本地用户登录后默认路径，否则默认在自己的家目录</span><br><span class="line">local_umask=022 #设置本地用户上传文件的权限</span><br><span class="line"></span><br><span class="line">listen=YES</span><br><span class="line">listen_ipv6=YES # 注释掉</span><br><span class="line">local_max_rate=0 # 限制最大传输速率</span><br><span class="line">write_enable=YES #是否允许写入，否则不能上传文件</span><br><span class="line">ftpd_banner=Welcome to blah FTP service. # ftp链接成功提示</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">配置文件 chroot_list</span></span><br><span class="line">chroot_local_user=YES # 本地用户不能切换到上级</span><br><span class="line">chroot_list_enable=YES #是否启用限制用户名单</span><br><span class="line">chroot_list_file=/etc/vsftpd/chroot_list # 如果开启就要指定路径，里面的用户不限制去上级</span><br><span class="line">allow_writeable_chroot=YES #如果文件不能上传 550 Permis....，可以加上这儿</span><br><span class="line">allow_writeable_chroot=YES &amp; setenforce 0 # 这个设为yes 并且 关闭eslinux，才能正常使用 chroot</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">配置文件 user_list</span></span><br><span class="line">userlist_enable=YES &amp; userlist_deny=YES # 禁止/etc/vsftpd/user_list 文件中的用户登录</span><br><span class="line">userlist_enable=YES &amp; userlist_deny=NO # 允许 /etc/vsftpd/user_list 文件中的用户登录</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">配置文件 ftpusers 权限高，里面所有用户都不允许登录，root默认在里面（（manjaro 没有））</span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">被动模式</span></span><br><span class="line">pasv_enable=YES # 启用被动模式，默认YES</span><br><span class="line">pasv_min_prot=40000</span><br><span class="line">pasv_max_prot=50000  # 指定被动模式端口范围</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">主动模式</span></span><br><span class="line">prot_enable=YES|NO # 是否取消主动模式 默认YES</span><br></pre></td></tr></table></figure>
<ol start="5">
<li>新建一个用户<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">配置一个用户</span></span><br><span class="line">useradd -s /sbin/nologin ftpuser</span><br><span class="line">passwd ftpuser</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">权限目录 默认 家目录</span></span><br><span class="line">mkdir /var/ftp/ftpupload</span><br><span class="line">chown -R ftpuser:ftpuser /var/ftp/ftpupload</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">备份配置文件</span></span><br><span class="line">cp /etc/vsftpd.conf /etc/vsftpd.conf.back</span><br><span class="line"></span><br><span class="line">pasv_address=114.115.121.129</span><br><span class="line">pasv_enable=YES</span><br><span class="line">pasv_min_port=30000</span><br><span class="line">pasv_max_port=50000</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">主机安全组配置30000-50000 和 21 端口的几率</span></span><br><span class="line"></span><br><span class="line">![华为主机配置](https://support.huaweicloud.com/bestpractice-ecs/zh-cn_topic_0115828034.html)</span><br></pre></td></tr></table></figure></li>
</ol>
</li>
<li><p>虚拟用户登录</p>
<ol>
<li>创建虚拟用户代替本地用户</li>
<li>使用<code>本地用户</code>作为<code>虚拟用户</code>的<code>映射用户</code>，为虚拟用户提供<code>工作目录</code>和<code>权限控制</code></li>
<li>能够设置严格权限，为每个虚拟用户生成单独配置文件</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">虚拟用户</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">1、/etc/vsftpd/ 建立FTP的虚拟用户数据库文件 vsftpd.user 随意</span></span><br><span class="line">user1</span><br><span class="line">pwd1</span><br><span class="line">user2</span><br><span class="line">pwd2     # 奇数行账号，偶数行密码</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">加密生成数据库文件</span></span><br><span class="line">db_load -T -t hash -f vsftpd.user vsftpd.db</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">设置 vsftpd.db 文件权限 保证安全</span></span><br><span class="line">chmod 600 vsftpd.db</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">创建虚拟映射用户 virturl，并指定用户家目录</span></span><br><span class="line">useradd -d /var/ftproot -s /sbin/nologin virturl</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">/var/ftproot 添加其他人权限</span></span><br><span class="line">chmod o+r /var/ftproot</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">建立支持虚拟用户的PAM任务文件 /etc/pam.d/vsftpd ，添加虚拟用户支持</span></span><br><span class="line">cp -a /etc/pam.d/vsftpd /etc/pam.d/vsftpd.pam</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">编辑 .pam （清空原来内容，添加下面两行）</span></span><br><span class="line">auth       required    pam_userdb.so db=/etc/vsftpd/vsftpd</span><br><span class="line">account    required    pam_userdb.so db=/etc/vsftpd/vsftpd</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">vsftpd.conf 文件添加支持</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">修改</span></span><br><span class="line">pam_service_name=vsftpd.pam</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">添加</span></span><br><span class="line">guest_enable=YES # 开启虚拟用户</span><br><span class="line">guest_username=virturl # 指定虚拟用户的映射用户</span><br><span class="line">user_config_dir=/etc/vsftpd/dir # 虚拟用户的配置目录，需要创建 /etc/vsftpd/dir </span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">关闭匿名用户的一些配置,除非都要用的，否则私有的要提到 <span class="built_in">dir</span> 下 单独配置</span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">/etc/vsftpd/dir/user1</span></span><br><span class="line">anon_upload_enable=YES # 允许 user1 上传文件</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">/etc/vsftpd/dir/user2</span></span><br><span class="line">anon_mkdir_write_enable=YES # 允许创建目录</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">/etc/vsftpd/dir/user3</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="built_in">chown</span> virturl:virturl /var/ftpuser1/  改变所有者与所属组</span></span><br><span class="line">write_enable=YES # 写权限，vsftpd.conf 有的这边就不要设置了</span><br><span class="line">anon_upload_enable=YES</span><br><span class="line">anon_mkdir_write_enable=YES </span><br><span class="line">anon_other_write_enable=YES # 删除/重命名的权限</span><br><span class="line">anon_world_readable_only=YES # 文件的其他人必须有读的权限才允许下载</span><br><span class="line">local_root=/var/ftpuser1  # 指定自己独有的家目录，不是 anon 就是 local开头</span><br><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>
</li>
<li><p><strong>配置文件中不能出现多余空格</strong></p>
</li>
</ol>
</li>
</ol>
<h3 id="DNS"><a href="#DNS" class="headerlink" title="DNS"></a>DNS</h3><p> 域名 指向一个 IP </p>
<p>DNS 就是域名和IP互相解析的一个服务</p>
<h4 id="域名的组成和分类"><a href="#域名的组成和分类" class="headerlink" title="域名的组成和分类"></a>域名的组成和分类</h4><blockquote>
<p>  常见完整格式 <code>www.atguigu.com.</code></p>
</blockquote>
<ol>
<li><code>.</code>：跟域，可以省略不写 ，所有 <code>com</code> <code>cn</code>等 顶级域，都是建立在跟域上的<ol>
<li>全球共13台根域名服务器。名字分别为“A”至“M”，10台在美国，另外各有一台设置于英国、瑞典和日本。<ol>
<li>分为1台主根，12台辅根，辅根数据也必须从主根同步</li>
</ol>
</li>
<li>所有根服务器均由美国政府授权的互联网域名与号码分配机构ICANN统一管理</li>
<li>国内设置<code>镜像根域.</code>使国内用户进行域名解析时效率更快，不要每次都跑国外去<ol>
<li><code>镜像根</code>的数据只能来源于根域服务器，从根域服务器同步，不能其他方式更新</li>
</ol>
</li>
</ol>
</li>
<li><code>com</code>：顶级域， ICANN组织指定和管理<ol>
<li>国家地区域名：<strong>cn 中国</strong>、<strong>hk 香港</strong>、<strong>sg 新加坡</strong> 等</li>
<li>通用顶级域名：<strong>com ( 商业机构 )<strong>、</strong>org ( 非盈利组织 )<strong>、</strong>edu ( 教育机构 )</strong> 等</li>
<li>新通用顶级域名：red   top</li>
</ol>
</li>
<li><code>atguigu</code>：二级域（ 注册与 )，个人或组织申请注册</li>
<li><code>www</code>：三级域 （ 子域 ），服务器网站代表</li>
<li><code>其他</code>：</li>
</ol>
<pre><code> 1.   `s1.www.xxxx.xx` s1代码某台主机
 2.   `com.cn` 属于二级域名，是 cn 顶级域的子域
</code></pre>
<h4 id="DNS域名解析过程"><a href="#DNS域名解析过程" class="headerlink" title="DNS域名解析过程"></a>DNS域名解析过程</h4><ol>
<li>客户端访问 <code>www.atguigu.com</code>  <ol>
<li>浏览器自动补齐<code>:80</code></li>
</ol>
</li>
<li>客户端首先查询自己的 hosts 文件，查看该文件内是否有 <code>www.atguigu.com</code> 的记录<ol>
<li>有 直接返回IP地址给浏览器</li>
</ol>
</li>
<li>客户端继续在本机内查询DNS的解析缓存<ol>
<li>有 直接返回给浏览器</li>
</ol>
</li>
<li>客户端查看网卡上设置的DNS服务器地址，访问DNS服务器，查询结果，<ol>
<li>若解析库有解析记录，返回给客户浏览器</li>
</ol>
</li>
<li>客户机设置的DNS服务器，解析库找不到，去该服务器缓存查找<ol>
<li>有 直接返回</li>
</ol>
</li>
<li>DNS服务器 向根域发起<code>迭代查询</code><ol>
<li>DNS 找到根域， 拿到<code>com</code> 顶级域 的 IP地址 ( 根域保存所有顶级域的IP地址 )</li>
<li>DNS 根据 <code>com</code>顶级域的IP 找到顶级域，获取二级域<code>atguigu</code>的ip地址 ( 顶级域储存所有二级域的IP地址 )</li>
<li>DNS 根据 <code>atguigu</code>二级域的地址找到二级域，获取 三级域<code>www</code>的 IP，这个就是我们需要的IP地址</li>
</ol>
</li>
<li>拿到真正的IP地址后，<strong>返回给客户端</strong>，并把这次这个新记录<strong>保存</strong>到自己DNS解析库和缓存中，下次就不要再<code>迭代查询</code>了</li>
</ol>
<p><img src= "" data-lazy-src="/../../static/img/2022-09-26_013055.jpg" alt="解析"></p>
<h4 id="分布式DNS服务器"><a href="#分布式DNS服务器" class="headerlink" title="分布式DNS服务器"></a>分布式DNS服务器</h4><blockquote>
<p>  同一个任务，由不同步骤共同完成的过程就叫分布式</p>
</blockquote>
<ul>
<li><p><code>根域</code>只管<code>顶级域</code>的IP地址</p>
</li>
<li><p><code>顶级域</code>只管<code>自己二级域</code>的IP地址 </p>
</li>
<li><p><code>二级域</code>只管<code>自己的三级域</code>的IP地址</p>
</li>
<li><p>DNS只负责找IP（自己储存库没有，就去外面找）</p>
</li>
<li><p>DNS服务器是不能个人进行部署的，需要向权威机构申请注册</p>
</li>
</ul>
<h4 id="负载均衡"><a href="#负载均衡" class="headerlink" title="负载均衡"></a>负载均衡</h4><blockquote>
<p>  数据量太大，需要多台DNS共同处理，就出现了<strong>负载均衡</strong>，客户机直接访问<strong>负载均衡服务器</strong>，负载均衡服务器再将用户的请求<strong>分发</strong>到适合的DNS服务器上</p>
</blockquote>
<p>负载均衡将用户的请求分配到多个功能相同的服务器</p>
<h4 id="DNS软件信息"><a href="#DNS软件信息" class="headerlink" title="DNS软件信息"></a>DNS软件信息</h4><p>软件名称 <code>bind</code> ，服务名称 <code>named</code> ，软件端口 <code>UDP 53</code> 和 <code>TCP 53</code></p>
<p>配置文件 <code>/etc/named.conf</code></p>
<h3 id="nc"><a href="#nc" class="headerlink" title="nc"></a>nc</h3><ul>
<li>安装 <code>nmap-ncat</code>或<code>nmap-netcat</code></li>
</ul>
<h3 id="openssh-远程连接工具"><a href="#openssh-远程连接工具" class="headerlink" title="openssh(远程连接工具)"></a>openssh(远程连接工具)</h3><blockquote>
<p>使其他设备可以通过 <code>xshell，mobaxterm 等工具远程连接</code></p>
</blockquote>
<ul>
<li><p>安装 openssh</p>
</li>
<li><p><code>system status ssh</code>:查看是否开启</p>
</li>
<li><p><code>lsof -i:22</code>:检测是否可以使用,默认 22 端口</p>
</li>
<li><p>mobaxterm 链接 图形界面</p>
<ul>
<li>首先目标linux系统需要支持<code>X11-forwarding</code></li>
<li>arch系列<ul>
<li>yay -S xorg-xauth</li>
<li>touch ~&#x2F;.Xauthority &amp;&amp; chmod 600 ~&#x2F;.Xauthority</li>
<li>sudo vim &#x2F;etc&#x2F;ssh&#x2F;sshd_config 将 AddressFamily any 改为 AddressFamily inet</li>
<li>sudo systemctl reload sshd.service &amp;&amp; sudo systemctl restart sshd.service</li>
</ul>
</li>
</ul>
</li>
</ul>
<h3 id="lsof"><a href="#lsof" class="headerlink" title="lsof"></a>lsof</h3><h3 id="wget"><a href="#wget" class="headerlink" title="wget"></a>wget</h3><h3 id="htop"><a href="#htop" class="headerlink" title="htop"></a>htop</h3><ul>
<li>通过上下左右控制，不能HJKL</li>
<li><code>F2</code>:显示界面设置，<code>空格</code>切换显示模式，<code>Available meters</code>回车，添加指定属性,delete删除</li>
<li><code>F3</code>:搜索</li>
<li><code>F4</code>:过滤(隐藏不匹配的进程)</li>
<li><code>F5</code>:进程树</li>
</ul>
<h3 id="docker"><a href="#docker" class="headerlink" title="docker"></a>docker</h3><blockquote>
<p>容器镜像服务，Docker理解成一个专门分装应用程序与执行环境的轻型虚拟机,作用镜像制作</p>
</blockquote>
<p><a target="_blank" rel="noopener" href="https://hub.docker.com/">镜像官网</a><br><a target="_blank" rel="noopener" href="https://quay.io/">其他镜像</a></p>
<ul>
<li>yay安装 ，通过systemctl开启服务</li>
<li>权限:<br>-   创建docker组，将相关用户归属组添加docker<br>-   sudo gpasswd -a username docker</li>
<li>刷新:newgrp docker<br>-   id username 查看是否添加成功</li>
<li>镜像</li>
<li>阿里云 -&gt; 控制台 -&gt; 产品与服务 -&gt; 搜索容器镜像服务-&gt; 加速配置<br>-   将他的配置json内容复制到&#x2F;etc&#x2F;docker&#x2F;daemon.json中</li>
<li>常用命令<br>-   <code>docker info</code>:查看docker基础信息<br>-   <code>docker search xxx</code>:查找镜像<br>-   <code>docker pull xxxname</code>:下载镜像<br>-   <code>docker images</code>:查看下载镜像的信息<br>-   <code>docker rmi IMAGE_ID|Tag</code>通过id或tag删除<br>-   <code>docker save -o centos.tar centos:7</code>:保存将名称:centos,tag：7的镜像输出中centos.tar文件中</li>
</ul>
<h4 id="常用基础环境服务"><a href="#常用基础环境服务" class="headerlink" title="常用基础环境服务"></a>常用基础环境服务</h4><ul>
<li><code>httpd</code>:Apache</li>
<li><code>busybox</code>：轻量嵌入式系统</li>
<li><code>centos</code>:系统镜像</li>
</ul>
<h4 id="lazydocker"><a href="#lazydocker" class="headerlink" title="lazydocker"></a>lazydocker</h4><blockquote>
<p>docker gui管理插件</p>
</blockquote>
<h3 id="samba"><a href="#samba" class="headerlink" title="samba"></a>samba</h3><blockquote>
<p>是一款linux系统应用微软文件资料的工具<br>微软指定了<code>SMB协议</code>，用于<code>局域网</code>文件共享，</p>
</blockquote>
<p>特点：<br>1、linux与Windows之间进行文件和打印机共享<br>2、适用于linux与linux，和linux与window<br>3、NFS个适合linux与linux的文件共享，所有samba一般用在 linux与window使用</p>
<p>安装</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">yum 安装配置文件一般在 /etc 下</span></span><br><span class="line">yum install samba -y</span><br><span class="line">cd /etc/samba</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">global 全局配置</span></span><br><span class="line">[global]</span><br><span class="line">    # 定义一个工作组</span><br><span class="line">	workgroup = SAMBA  </span><br><span class="line">    # 安全验证方式 user代表账号密码</span><br><span class="line">	security = user</span><br><span class="line"></span><br><span class="line">	passdb backend = tdbsam</span><br><span class="line"></span><br><span class="line">	printing = cups</span><br><span class="line">	printcap name = cups</span><br><span class="line">	load printers = yes</span><br><span class="line">	cups options = raw</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">下面的都是独立局部配置，如:home下面的配置，只对homes文件夹生效</span> </span><br><span class="line">[homes]</span><br><span class="line">	comment = Home Directories</span><br><span class="line">	valid users = %S, %D%w%S</span><br><span class="line">	browseable = No</span><br><span class="line">	read only = No</span><br><span class="line">	inherit acls = Yes</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p>案例<br>1、建立共享文件夹</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">[testshare]</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">描述</span></span><br><span class="line">	comment = All Printers</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">共享路径</span></span><br><span class="line">	path = /var/tmp</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">是否公开</span></span><br><span class="line">    public = no</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">是否可以写入</span></span><br><span class="line">    writable = yes</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">是否允许匿名用户登录</span></span><br><span class="line">    guest ok = yes</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>2、使用pdbedit 创建samba服务专用的密码信息<br>3、使用pdbedit管理samba用户,这个用户必须是linux用户</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">创建用户</span></span><br><span class="line">pdbedit -a -u user-name</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p>4、重启smb服务，并检查samba端口(445)是否存活<br>5、检测防火墙<br>iptables -L</p>
<p>6、使用客户端链接</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">window</span></span><br><span class="line">运行输入</span><br><span class="line">//sam服务器地址</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">macos</span></span><br><span class="line">smb://sma服务器地址</span><br><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>
<h3 id="NFS"><a href="#NFS" class="headerlink" title="NFS"></a>NFS</h3><blockquote>
<p>稳定的网络文件共享系统，与云服务器的共享<br>软件共享存储，大公司有可能需要购买硬件设备分担压力,成本高<br>统一存储网站静态数据<br><img src= "" data-lazy-src="/../../static/img/NFS1.png" alt="NFS"></p>
</blockquote>
<blockquote>
<p>NFS 和 RPC<br>1、NFS通过port传输数据，端口是随机的,主动再RPC进行注册（重启NFS，查看端口是否变化）<br>2、所以需要通过<code>RPC</code>服务进行端口注册，实现告知用户NFS端口是什么<br>3、所以RPC(远程过程调用)，NFS两个服务一起启动<br>4、过程：NFS（客户端）发送请求(端口111)到RPC，从而得到一个端口，再拿端口去访问远程NFS服务端</p>
</blockquote>
<blockquote>
<p>环境搭建<br>1、安装 rpcbind<br>2、安装 nfs-utils</p>
</blockquote>
<blockquote>
<p>环境配置<br>1、NFS是c&#x2F;s模式，client,server 准备台机器<br>2、NFSServer创建共享文件夹，并给与权限<br>3、修改NFSServer配置文件</p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">/etc/exports</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">配置文件规则</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">NFS服务端共享目录 NFS客户端地址(参数...) NFS客户端地址2(参数...)</span></span><br><span class="line">/root/nfsshare *(ro)  #所有人可读</span><br><span class="line">/root/nfsshare 主机名(rw) 主机名2(rw)  允许这两个主机可读写</span><br><span class="line">/root/nfsshare IP(insecure,rw,root_squash) 允许这个IP可读写</span><br><span class="line">/root/nfsshare 192.168.178.0/24(rw) 允许整个178网段访问（24 子网掩码24位，255.255.255.0）</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">权限参数</span></span><br><span class="line">insecure 允许客户端从大于1024的端口发请求(参数1必须加)</span><br><span class="line">ro  只读</span><br><span class="line">rw  读写</span><br><span class="line">root_squash 如果客户端以root访问服务端nfs时，会把该用户映射位匿名用户，UID GID会变成nfsnobody的信息</span><br><span class="line">no_root_squash 和上面相反不安全</span><br><span class="line">all_squash 无论是root还是非root，全部匿名，很安全</span><br><span class="line">sync 数据同步写入到磁盘和内存，保证数据安全，但效率低</span><br><span class="line">async 数据线写入到内存，再持久化到磁盘效率高</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p>4、启动NFS服务的文件共享目录</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">NFS基于RPC111端口，保证RPC以及启动,111 端口启动</span></span><br><span class="line">systemctl start rpcbind</span><br><span class="line">netstat -tunlp|grep 111</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">写好NFS配置文件与挂载目录</span></span><br><span class="line">chmod -Rf 777 path  强制递归给与权限</span><br><span class="line">chown -r nfsnobody:nfsnobody path</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">启动NFS</span></span><br><span class="line">systemctl start nfs-server.service （centos8专的版本）</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">检测本地共享情况</span></span><br><span class="line">showmount -e 127.0.0.1</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">检测共享参数</span></span><br><span class="line">/var/lib/nfs/etab</span><br></pre></td></tr></table></figure>

<p>5、本地挂载测试<br>mount -t nfs 114.115.212.xxx:&#x2F;root&#x2F;nfsshare &#x2F;mnt<br>umount &#x2F;mnt 取消挂载 </p>
<p>6、客户端挂载</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">确保安装了nfs-utils和rpcbind</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">开启rpcbind</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">检测服务端共享是否可用，如果通了就能进行挂载操作</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">云服务器安全组需要开发111端口</span></span><br><span class="line">showmount -e 服务端IP </span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">mount -t -nfs xxxxx</span></span><br><span class="line"></span><br></pre></td></tr></table></figure>



<h3 id="postfix-dovecot-收发邮件"><a href="#postfix-dovecot-收发邮件" class="headerlink" title="postfix + dovecot 收发邮件"></a>postfix + dovecot 收发邮件</h3><p> 每个企业的邮箱都有 客户端 和  </p>
<h3 id="VNC-远程linux图形界面"><a href="#VNC-远程linux图形界面" class="headerlink" title="VNC 远程linux图形界面"></a>VNC 远程linux图形界面</h3><p>服务端</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">yum install tigervnc-server</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">设置分辨率</span></span><br><span class="line">vncserver -geometry 1920x1080</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">启动服务</span></span><br><span class="line">vncserver</span><br><span class="line">    输入至少六位密码</span><br><span class="line">    验证前面数的密码</span><br><span class="line">    第三个选n</span><br><span class="line">    等待服务开启....</span><br><span class="line"></span><br><span class="line">vncserver -list  查看端口与进程, 完成后去客户端</span><br><span class="line"></span><br><span class="line">防火墙开放这个端口或关闭防火墙</span><br></pre></td></tr></table></figure>

<p>进入官网下载客户端 下载<code>vnc viewer</code>桌面程序<br>    <a target="_blank" rel="noopener" href="https://downloads.realvnc.com/download/file/viewer.files/VNC-Viewer-6.22.515-Windows-64bit.exe">https://downloads.realvnc.com/download/file/viewer.files/VNC-Viewer-6.22.515-Windows-64bit.exe</a></p>
<p>新建链接<br>输入 ip与端口<br>名称随意 root</p>
<h3 id="备份"><a href="#备份" class="headerlink" title="备份"></a>备份</h3><p><code>FreeFileSync</code>: <a target="_blank" rel="noopener" href="https://freefilesync.com/">数据备份软件</a></p>
<ol>
<li><p>手动备份</p>
<ul>
<li>选择连个文件夹，比较可以看到差异文件，选择同步方式进行同步</li>
<li>设置一次后，可以保存为批处理作业，变成开启执行，后手动点击直接同步</li>
</ul>
</li>
<li><p>监视备份 <code>RealTimeSync</code></p>
<ul>
<li>可以添加很多个监视文件夹，设置空闲事件，每隔这么多秒，就去查看监视的文件夹是否有变化</li>
<li>如果有变化就会执行下面命令行(命令可以把 前面的批处理作业拖进来)</li>
</ul>
</li>
<li><p>通过 window 的任务计划程序定时执行<code>批处理作业</code>，linux可以用cron</p>
</li>
</ol>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="http://example.com">lzoxun</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="http://example.com/2023/07/22/linux/linux-servers/">http://example.com/2023/07/22/linux/linux-servers/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="http://example.com" target="_blank">学习笔记</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"></div><div class="post_share"><div class="social-share" data-image="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/2023/07/22/linux/linux-shell-config-path/" title="配置路径"><div class="cover" style="background: var(--default-bg-color)"></div><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">配置路径</div></div></a></div><div class="next-post pull-right"><a href="/2023/07/22/linux/linux-shell/" title="shell"><div class="cover" style="background: var(--default-bg-color)"></div><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">shell</div></div></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src= "" data-lazy-src="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">lzoxun</div><div class="author-info__description"></div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">108</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">1</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">0</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/liaozhongxun"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/liaozhongxun" target="_blank" title="Github"><i class="fab fa-github" style="color: #24292e;"></i></a><a class="social-icon" href="mailto:869664233@gmail.com" target="_blank" title="Email"><i class="fas fa-envelope" style="color: #4a7dbe;"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">这是我的文档</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-3"><a class="toc-link" href="#FTP"><span class="toc-number">1.</span> <span class="toc-text">FTP</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E7%BB%88%E7%AB%AFftp"><span class="toc-number">1.1.</span> <span class="toc-text">终端ftp</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%AE%A2%E6%88%B7%E7%AB%AF"><span class="toc-number">1.2.</span> <span class="toc-text">客户端</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%9C%8D%E5%8A%A1%E7%AB%AF-vsftpd-%E6%90%AD%E5%BB%BA-ftp-%E7%8E%AF%E5%A2%83"><span class="toc-number">1.3.</span> <span class="toc-text">服务端 vsftpd 搭建 ftp 环境</span></a></li></ol></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%AE%89%E8%A3%85-%E5%AE%89%E8%A3%85-vsftpd-systemctl-enable-vsftpd-%E5%BC%80%E6%9C%BA%E8%87%AA%E5%90%AF%E6%9C%8D%E5%8A%A1-systemctl-start-vsftpd-%E5%90%AF%E5%8A%A8%E6%9C%8D%E5%8A%A1-netstat-antp-%E6%9F%A5%E7%9C%8B21%E7%AB%AF%E5%8F%A3%E6%98%AF%E5%90%A6%E5%BC%80%E5%90%AF"><span class="toc-number"></span> <span class="toc-text">安装-   安装 vsftpd-   systemctl enable vsftpd 开机自启服务-   systemctl start vsftpd 启动服务-   netstat -antp 查看21端口是否开启</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#DNS"><span class="toc-number">1.</span> <span class="toc-text">DNS</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%9F%9F%E5%90%8D%E7%9A%84%E7%BB%84%E6%88%90%E5%92%8C%E5%88%86%E7%B1%BB"><span class="toc-number">1.1.</span> <span class="toc-text">域名的组成和分类</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#DNS%E5%9F%9F%E5%90%8D%E8%A7%A3%E6%9E%90%E8%BF%87%E7%A8%8B"><span class="toc-number">1.2.</span> <span class="toc-text">DNS域名解析过程</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%88%86%E5%B8%83%E5%BC%8FDNS%E6%9C%8D%E5%8A%A1%E5%99%A8"><span class="toc-number">1.3.</span> <span class="toc-text">分布式DNS服务器</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1"><span class="toc-number">1.4.</span> <span class="toc-text">负载均衡</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#DNS%E8%BD%AF%E4%BB%B6%E4%BF%A1%E6%81%AF"><span class="toc-number">1.5.</span> <span class="toc-text">DNS软件信息</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#nc"><span class="toc-number">2.</span> <span class="toc-text">nc</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#openssh-%E8%BF%9C%E7%A8%8B%E8%BF%9E%E6%8E%A5%E5%B7%A5%E5%85%B7"><span class="toc-number">3.</span> <span class="toc-text">openssh(远程连接工具)</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#lsof"><span class="toc-number">4.</span> <span class="toc-text">lsof</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#wget"><span class="toc-number">5.</span> <span class="toc-text">wget</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#htop"><span class="toc-number">6.</span> <span class="toc-text">htop</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#docker"><span class="toc-number">7.</span> <span class="toc-text">docker</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%B8%B8%E7%94%A8%E5%9F%BA%E7%A1%80%E7%8E%AF%E5%A2%83%E6%9C%8D%E5%8A%A1"><span class="toc-number">7.1.</span> <span class="toc-text">常用基础环境服务</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#lazydocker"><span class="toc-number">7.2.</span> <span class="toc-text">lazydocker</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#samba"><span class="toc-number">8.</span> <span class="toc-text">samba</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#NFS"><span class="toc-number">9.</span> <span class="toc-text">NFS</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#postfix-dovecot-%E6%94%B6%E5%8F%91%E9%82%AE%E4%BB%B6"><span class="toc-number">10.</span> <span class="toc-text">postfix + dovecot 收发邮件</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#VNC-%E8%BF%9C%E7%A8%8Blinux%E5%9B%BE%E5%BD%A2%E7%95%8C%E9%9D%A2"><span class="toc-number">11.</span> <span class="toc-text">VNC 远程linux图形界面</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%A4%87%E4%BB%BD"><span class="toc-number">12.</span> <span class="toc-text">备份</span></a></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/07/22/window/win-11/" title="win 11 set">win 11 set</a><time datetime="2023-07-22T07:14:09.700Z" title="发表于 2023-07-22 15:14:09">2023-07-22</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/07/22/window/win-gitbash/" title="git bash">git bash</a><time datetime="2023-07-22T07:14:09.700Z" title="发表于 2023-07-22 15:14:09">2023-07-22</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/07/22/window/win-wsl/" title="wsl">wsl</a><time datetime="2023-07-22T07:14:09.700Z" title="发表于 2023-07-22 15:14:09">2023-07-22</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/07/22/window/win-main/" title="window">window</a><time datetime="2023-07-22T07:14:09.700Z" title="发表于 2023-07-22 15:14:09">2023-07-22</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/07/22/web/%E5%85%BC%E5%AE%B9%E9%97%AE%E9%A2%98/" title="兼容问题">兼容问题</a><time datetime="2023-07-22T07:14:09.699Z" title="发表于 2023-07-22 15:14:09">2023-07-22</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2023 By lzoxun</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="translateLink" type="button" title="简繁转换">繁</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="/js/tw_cn.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.umd.min.js"></script><script src="https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module"></script><script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script><script src="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js"></script><script>function panguFn () {
  if (typeof pangu === 'object') pangu.autoSpacingPage()
  else {
    getScript('https://cdn.jsdelivr.net/npm/pangu/dist/browser/pangu.min.js')
      .then(() => {
        pangu.autoSpacingPage()
      })
  }
}

function panguInit () {
  if (false){
    GLOBAL_CONFIG_SITE.isPost && panguFn()
  } else {
    panguFn()
  }
}

document.addEventListener('DOMContentLoaded', panguInit)</script><div class="js-pjax"></div><script id="canvas_nest" defer="defer" color="0,0,255" opacity="0.7" zIndex="-1" count="99" mobile="false" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/canvas-nest.min.js"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div class="no-result" id="local-search-results"></div><div id="local-search-stats-wrap"></div></div></div><div id="search-mask"></div><script src="/js/search/local-search.js"></script></div></div><script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"log":false,"model":{"jsonPath":"/live2dw/assets/haruto.model.json"},"display":{"position":"right","width":100,"height":200,"right":300},"mobile":{"show":true}});</script></body></html>